#pragma once

#include <thread>
#include <chrono>
#include <random>


namespace evm {

double time();

struct Timeit {
    Timeit();

    double get();

private:
    double start_at;
};

/* High-resolution monotonic sleep */
void sleep(double seconds);

struct RandomSleep {
    RandomSleep(double min, double max)
            : uniform_dist(static_cast<int>(min * 1000), static_cast<int>(max * 1000))
    {}

    void operator()() {
        //std::this_thread::sleep_for(std::chrono::seconds(static_cast<long>(uniform_dist(re) / 1000.0)));
        sleep(uniform_dist(re) / 1000.0);
    }

private:
    static std::random_device rd;
    static std::default_random_engine re;
    std::uniform_int_distribution<int> uniform_dist;
};

}
